package oop3.pet;

public final class Cat extends Pet {
	private String type;// 类别
	private String sex;

	public Cat(String name, int health, int love, String type, String sex) {
		super(health, love);// 调用父类的构造方法
		this.type = type;
		this.sex = sex;
		super.name = name;
	}

	public void catchMouse(String s) {
		System.out.println(super.getName() + "抓住了老鼠" + s + ",立了大功");

	}

	@Override // 注解
	public void show() {
		System.out.println("这是一只猫，" + type + "，性别是" + sex);
		super.show();
	}

	@Override
	public String toString() {
		return "小猫" + this.type + ",性别是:" + this.sex + super.toString();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		// obj墙砖(强转)成Cat
		if (!(obj instanceof Cat)) {
			return false;
		}
		Cat cat = (Cat) obj;
		// 确定比较规则：type和name一致的，认为他逻辑上是一样的
		return this.type.equals(cat.type) && this.name.equals(this.getName());
	}

	@Override
	public void cry() {
		System.out.println("喵喵喵");
	}
}
